<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>浙江在线预约诊疗服务平台</title>
    <link rel="stylesheet" href="public/css/lib/bootstrap.min.css" tppabs="https://guahao.zjol.com.cn/public/css/lib/bootstrap.min.css">
    <link rel="stylesheet" href="public/css/lib/glider.min.css" tppabs="https://guahao.zjol.com.cn/public/css/lib/glider.min.css">
    <link rel="stylesheet" href="public/css/lib/bootstrap-datepicker.min.css" tppabs="https://guahao.zjol.com.cn/public/css/lib/bootstrap-datepicker.min.css">
    <link rel="stylesheet" href="public/css/lib/jquery-confirm.min.css" tppabs="https://guahao.zjol.com.cn/public/css/lib/jquery-confirm.min.css">


    <!-- <link rel="stylesheet" href="/public/css/lib/material-icons.css">
    <link rel="stylesheet" href="/public/css/lib/bootstrap-material-design.min.css" > -->

    <link rel="stylesheet" href="public/css/global.css" tppabs="https://guahao.zjol.com.cn/public/css/global.css">


    <link rel="stylesheet" href="public/css/register.css" tppabs="https://guahao.zjol.com.cn/public/css/register.css">

</head>

<body>

<div class="login-box">
    <div class="login-container clearfix">
        <div class="login-left float-left">
        </div>
        <div class="login-right float-left">
            <div class="login-title">
                <a href="login.html" tppabs="https://guahao.zjol.com.cn/login" style="color: #2f2f2f;">登录</a>
                <span class="active">注册</span>
            </div>
            <div class="login-content">
                <div class="login-item">
                    <div class="login-item-name">手机号<span class="login-ntf name" id="phone2"></span></div>
                    <div class="login-item-ipt">
                        <input type="text" class="form-control username-ipt" placeholder="请输入手机号" id="phone">
                    </div>

                </div>

                <div class="login-item">
                    <div class="login-item-name">手机验证码<span class="login-ntf name" id="captcha2"></span></div>
                    <div class="login-item-ipt clearfix">
                        <div class="float-left" style="width: 60%;">
                            <input type="text" class="form-control verify-ipt" placeholder="请输入手机验证码" id="captcha">
                        </div>
                        <div class="float-left" style="width: 40%; padding-left: 30px;">
                            <button type="button" id="verify-btn" class="btn btn-success btn-block">获取验证码</button>
                        </div>
                    </div>
                </div>

                <div class="login-item">
                    <div class="login-item-name">设置密码<span class="login-ntf password"></span></div>
                    <div class="login-item-ipt">
                        <input type="password" id="password" class="form-control password-ipt" placeholder="请设置密码">
                    </div>
                </div>

                <div class="login-item">
                    <div class="login-item-name">确认密码<span class="login-ntf password-check" id="password3"></span></div>
                    <div class="login-item-ipt">
                        <input type="password" id="check-password" class="form-control check-password-ipt" placeholder="请确认密码">
                    </div>
                </div>

                <div style="margin-top: 20px;">
                    <button class="btn btn-success btn-block" id="submit" type="submit">注&nbsp;&nbsp;册</button>
                </div>

            </div>
        </div>
    </div>
</div>

</body>
<script src="../admin/js/jquery.js"></script>
<script>

    $(function(){
        $("#verify-btn").click(function(){
            var phone=$("#phone").val();
            var codeType=1;
            $.ajax({
                type: "post",
                url: "/hospital/api/sms/verfycode",
                data: {
                    "codeType":codeType,
                    /* sms: sms,*/
                    "phone": phone
                },
                dataType: "json",
                success: function (data) {
                    console.log(data);
                }
            })
        })

        $("#submit").click(function(){
            $("#phone2").html("");
            $("#captcha2").html("");
            $("#password3").html("");
            var token = localStorage.getItem("token");
            var head = new Headers();
            head.append('token', token);
            var phone=$("#phone").val();
            var captcha=$("#captcha").val();
            var password=$("#password").val();
            var password2=$("#check-password").val();
            if((/^1\d{10}$/.test(phone))){
                /*if((/^\d{4}$/.test(captcha))){*/
                if(password==password2 && password!=null){
                    $.ajax({
                        type: "post",
                        url: "/hospital/api/user/register/login/sms",
                        data: {
                            "phone": phone,
                            /* sms: sms,*/
                            password: password
                        },
                        dataType: "json",
                        headers: {
                            'token': token
                        },
                        success: function (data, textStatus, request) {
                            if (data.code == 0) {
                                alert("注册成功")
                                localStorage.setItem("token", request.getResponseHeader("token"));
                                location.href = "home.html"
                            } else if (data.code == 200004) {
                                alert(data.msg)
                                $("#captcha2").append("验证码错误")
                            } else {
                                alert(data.msg)
                            }
                        }
                    })
                }else {
                    $("#password3").append("密码不能为空或密码不一致")
                }
                /* }else {
                 $("#captcha2").append("验证码必须为4位数")
               }*/
            }else{
                $("#phone2").append("手机格式不正确")
            }
        })
    })
</script>
</html>